home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / djgpp / docs / binutils / ld.i1 < prev    next >
Encoding:
GNU Info File  |  1994-12-17  |  49.6 KB  |  1,273 lines

  1. This is Info file ld.info, produced by Makeinfo-1.55 from the input
  2. file ./ld.texinfo.
  3.  
  4. START-INFO-DIR-ENTRY
  5. * Ld: (ld).                       The GNU linker.
  6. END-INFO-DIR-ENTRY
  7.  
  8.    This file documents the GNU linker LD.
  9.  
  10.    Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided also
  18. that the entire resulting derived work is distributed under the terms
  19. of a permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions.
  24.  
  25. 
  26. File: ld.info,  Node: Top,  Next: Overview,  Prev: (DIR),  Up: (DIR)
  27.  
  28. Using ld
  29. ********
  30.  
  31.    This file documents the GNU linker ld.
  32.  
  33. * Menu:
  34.  
  35. * Overview::                    Overview
  36. * Invocation::                  Invocation
  37. * Commands::                    Command Language
  38.  
  39. * Machine Dependent::           Machine Dependent Features
  40.  
  41. * BFD::                         BFD
  42.  
  43. * MRI::                         MRI Compatible Script Files
  44. * Index::                       Index
  45.  
  46. 
  47. File: ld.info,  Node: Overview,  Next: Invocation,  Prev: Top,  Up: Top
  48.  
  49. Overview
  50. ********
  51.  
  52.    `ld' combines a number of object and archive files, relocates their
  53. data and ties up symbol references. Usually the last step in compiling
  54. a program is to run `ld'.
  55.  
  56.    `ld' accepts Linker Command Language files written in a superset of
  57. AT&T's Link Editor Command Language syntax, to provide explicit and
  58. total control over the linking process.
  59.  
  60.    This version of `ld' uses the general purpose BFD libraries to
  61. operate on object files. This allows `ld' to read, combine, and write
  62. object files in many different formats--for example, COFF or `a.out'.
  63. Different formats may be linked together to produce any available kind
  64. of object file.  *Note BFD::, for more information.
  65.  
  66.    Aside from its flexibility, the GNU linker is more helpful than other
  67. linkers in providing diagnostic information.  Many linkers abandon
  68. execution immediately upon encountering an error; whenever possible,
  69. `ld' continues executing, allowing you to identify other errors (or, in
  70. some cases, to get an output file in spite of the error).
  71.  
  72. 
  73. File: ld.info,  Node: Invocation,  Next: Commands,  Prev: Overview,  Up: Top
  74.  
  75. Invocation
  76. **********
  77.  
  78.    The GNU linker `ld' is meant to cover a broad range of situations,
  79. and to be as compatible as possible with other linkers.  As a result,
  80. you have many choices to control its behavior.
  81.  
  82. * Menu:
  83.  
  84. * Options::                     Command Line Options
  85. * Environment::                 Environment Variables
  86.  
  87. 
  88. File: ld.info,  Node: Options,  Next: Environment,  Up: Invocation
  89.  
  90. Command Line Options
  91. ====================
  92.  
  93.    Here is a summary of the options you can use on the `ld' command
  94. line:
  95.  
  96.      ld [ -o OUTPUT ]  OBJFILE...
  97.        [ -AARCHITECTURE ]  [ -b INPUT-FORMAT ]  [ -Bstatic ]
  98.        [ -c MRI-COMMANDFILE ]  [ -d | -dc | -dp ]
  99.        [ -defsym SYMBOL=EXPRESSION ]
  100.        [ -dynamic-linker FILE ]
  101.        [ -e ENTRY ]  [ -F ]  [ -F FORMAT ]
  102.        [ -format INPUT-FORMAT ]  [ -g ]  [ -G SIZE ]  [ -help ]
  103.        [ -i ]  [ -lARCHIVE ]  [ -LSEARCHDIR ]  [ -M ]
  104.        [ -Map MAPFILE ]  [ -m EMULATION ]  [ -N | -n ]
  105.        [ -noinhibit-exec ]  [ -oformat OUTPUT-FORMAT ]
  106.        [ -R FILENAME ]  [ -relax ]  [ -retain-symbols-file FILENAME ]
  107.        [ -r | -Ur ]  [ -rpath DIR ] [ -S ]  [ -s ] [ -soname NAME ]
  108.        [ -sort-common ] [ -stats ] [ -T COMMANDFILE ]
  109.        [ -Ttext ORG ]  [ -Tdata ORG ]
  110.        [ -Tbss ORG ]  [ -t ] [ -traditional-format ]
  111.        [ -u SYMBOL]  [-V]  [-v]  [ -verbose]  [ -version ]
  112.        [ -warn-common ]  [ -warn-once ] [ -y SYMBOL ]  [ -X ]  [-x ]
  113.        [ -( [ archives ] -) ] [ --start-group [ archives ] --end-group ]
  114.  
  115.    This plethora of command-line options may seem intimidating, but in
  116. actual practice few of them are used in any particular context.  For
  117. instance, a frequent use of `ld' is to link standard Unix object files
  118. on a standard, supported Unix system.  On such a system, to link a file
  119. `hello.o':
  120.  
  121.      ld -o OUTPUT /lib/crt0.o hello.o -lc
  122.  
  123.    This tells `ld' to produce a file called OUTPUT as the result of
  124. linking the file `/lib/crt0.o' with `hello.o' and the library `libc.a',
  125. which will come from the standard search directories.  (See the
  126. discussion of the `-l' option below.)
  127.  
  128.    The command-line options to `ld' may be specified in any order, and
  129. may be repeated at will.  Repeating most options with a different
  130. argument will either have no further effect, or override prior
  131. occurrences (those further to the left on the command line) of that
  132. option.
  133.  
  134.    The exceptions--which may meaningfully be used more than once--are
  135. `-A', `-b' (or its synonym `-format'), `-defsym', `-L', `-l', `-R',
  136. `-u', and `-(' (or its synonym `--start-group')..
  137.  
  138.    The list of object files to be linked together, shown as OBJFILE...,
  139. may follow, precede, or be mixed in with command-line options, except
  140. that an OBJFILE argument may not be placed between an option and its
  141. argument.
  142.  
  143.    Usually the linker is invoked with at least one object file, but you
  144. can specify other forms of binary input files using `-l', `-R', and the
  145. script command language.  If *no* binary input files at all are
  146. specified, the linker does not produce any output, and issues the
  147. message `No input files'.
  148.  
  149.    If the linker can not recognize the format of an object file, it will
  150. assume that it is a linker script.  A script specified in this way
  151. augments the main linker script used for the link (either the default
  152. linker script or the one specified by using `-T').  This feature
  153. permits the linker to link against a file which appears to be an object
  154. or an archive, but actually merely defines some symbol values, or uses
  155. `INPUT' or `GROUP' to load other objects.  *Note Commands::.
  156.  
  157.    For options whose names are a single letter, option arguments must
  158. either follow the option letter without intervening whitespace, or be
  159. given as separate arguments immediately following the option that
  160. requires them.
  161.  
  162.    For options whose names are multiple letters, either one dash or two
  163. can precede the option name; for example, `--oformat' and `-oformat'
  164. are equivalent.  Arguments to multiple-letter options must either be
  165. separated from the option name by an equals sign, or be given as
  166. separate arguments immediately following the option that requires them.
  167. For example, `--oformat srec' and `--oformat=srec' are equivalent.
  168. Unique abbreviations of the names of multiple-letter options are
  169. accepted.
  170.  
  171. `-AARCHITECTURE'
  172.      In the current release of `ld', this option is useful only for the
  173.      Intel 960 family of architectures.  In that `ld' configuration, the
  174.      ARCHITECTURE argument identifies the particular architecture in
  175.      the 960 family, enabling some safeguards and modifying the
  176.      archive-library search path.  *Note `ld' and the Intel 960 family:
  177.      i960, for details.
  178.  
  179.      Future releases of `ld' may support similar functionality for
  180.      other architecture families.
  181.  
  182. `-b INPUT-FORMAT'
  183.      `ld' may be configured to support more than one kind of object
  184.      file.  If your `ld' is configured this way, you can use the `-b'
  185.      option to specify the binary format for input object files that
  186.      follow this option on the command line.  Even when `ld' is
  187.      configured to support alternative object formats, you don't
  188.      usually need to specify this, as `ld' should be configured to
  189.      expect as a default input format the most usual format on each
  190.      machine.  INPUT-FORMAT is a text string, the name of a particular
  191.      format supported by the BFD libraries.  (You can list the
  192.      available binary formats with `objdump -i'.)
  193.      `-format INPUT-FORMAT' has the same effect, as does the script
  194.      command `TARGET'.  *Note BFD::.
  195.  
  196.      You may want to use this option if you are linking files with an
  197.      unusual binary format.  You can also use `-b' to switch formats
  198.      explicitly (when linking object files of different formats), by
  199.      including `-b INPUT-FORMAT' before each group of object files in a
  200.      particular format.
  201.  
  202.      The default format is taken from the environment variable
  203.      `GNUTARGET'.  *Note Environment::.  You can also define the input
  204.      format from a script, using the command `TARGET'; see *Note Option
  205.      Commands::.
  206.  
  207. `-Bstatic'
  208.      Do not link against shared libraries.  This option is accepted for
  209.      command-line compatibility with the SunOS linker.
  210.  
  211. `-c MRI-COMMANDFILE'
  212.      For compatibility with linkers produced by MRI, `ld' accepts script
  213.      files written in an alternate, restricted command language,
  214.      described in *Note MRI Compatible Script Files: MRI.  Introduce
  215.      MRI script files with the option `-c'; use the `-T' option to run
  216.      linker scripts written in the general-purpose `ld' scripting
  217.      language.  If MRI-CMDFILE does not exist, `ld' looks for it in the
  218.      directories specified by any `-L' options.
  219.  
  220. `-d'
  221. `-dc'
  222. `-dp'
  223.      These three options are equivalent; multiple forms are supported
  224.      for compatibility with other linkers.  They assign space to common
  225.      symbols even if a relocatable output file is specified (with
  226.      `-r').  The script command `FORCE_COMMON_ALLOCATION' has the same
  227.      effect.  *Note Option Commands::.
  228.  
  229. `-defsym SYMBOL=EXPRESSION'
  230.      Create a global symbol in the output file, containing the absolute
  231.      address given by EXPRESSION.  You may use this option as many
  232.      times as necessary to define multiple symbols in the command line.
  233.      A limited form of arithmetic is supported for the EXPRESSION in
  234.      this context: you may give a hexadecimal constant or the name of
  235.      an existing symbol, or use `+' and `-' to add or subtract
  236.      hexadecimal constants or symbols.  If you need more elaborate
  237.      expressions, consider using the linker command language from a
  238.      script (*note Assignment: Symbol Definitions: Assignment.).
  239.      *Note:*  there should be no white space between SYMBOL, the equals
  240.      sign ("="), and EXPRESSION.
  241.  
  242. `-dynamic-linker FILE'
  243.      Set the name of the dynamic linker.  This is only meaningful when
  244.      generating dynamically linked ELF executables.  The default dynamic
  245.      linker is normally correct; don't use this unless you know what
  246.      you are doing.
  247.  
  248. `-e ENTRY'
  249.      Use ENTRY as the explicit symbol for beginning execution of your
  250.      program, rather than the default entry point. *Note Entry Point::,
  251.      for a discussion of defaults and other ways of specifying the
  252.      entry point.
  253.  
  254. `-F'
  255. `-FFORMAT'
  256.      Ignored.  Some older linkers used this option throughout a
  257.      compilation toolchain for specifying object-file format for both
  258.      input and output object files.  The mechanisms `ld' uses for this
  259.      purpose (the `-b' or `-format' options for input files, `-oformat'
  260.      option or the `TARGET' command in linker scripts for output files,
  261.      the `GNUTARGET' environment variable) are more flexible, but `ld'
  262.      accepts the `-F' option for compatibility with scripts written to
  263.      call the old linker.
  264.  
  265. `-format INPUT-FORMAT'
  266.      Synonym for `-b INPUT-FORMAT'.
  267.  
  268. `-g'
  269.      Ignored.  Provided for compatibility with other tools.
  270.  
  271. `-GVALUE'
  272. `-G VALUE'
  273.      Set the maximum size of objects to be optimized using the GP
  274.      register to SIZE under MIPS ECOFF.  Ignored for other object file
  275.      formats.
  276.  
  277. `-help'
  278.      Print a summary of the command-line options on the standard output
  279.      and exit.
  280.  
  281. `-i'
  282.      Perform an incremental link (same as option `-r').
  283.  
  284. `-lAR'
  285.      Add archive file ARCHIVE to the list of files to link.  This
  286.      option may be used any number of times.  `ld' will search its
  287.      path-list for occurrences of `libAR.a' for every ARCHIVE specified.
  288.  
  289. `-LSEARCHDIR'
  290. `-L SEARCHDIR'
  291.      Add path SEARCHDIR to the list of paths that `ld' will search for
  292.      archive libraries and `ld' control scripts.  You may use this
  293.      option any number of times.
  294.  
  295.      The default set of paths searched (without being specified with
  296.      `-L') depends on which emulation mode `ld' is using, and in some
  297.      cases also on how it was configured.  *Note Environment::.
  298.  
  299.      The paths can also be specified in a link script with the
  300.      `SEARCH_DIR' command.
  301.  
  302. `-M'
  303.      Print (to the standard output) a link map--diagnostic information
  304.      about where symbols are mapped by `ld', and information on global
  305.      common storage allocation.
  306.  
  307. `-Map MAPFILE'
  308.      Print to the file MAPFILE a link map--diagnostic information about
  309.      where symbols are mapped by `ld', and information on global common
  310.      storage allocation.
  311.  
  312. `-mEMULATION'
  313. `-m EMULATION'
  314.      Emulate the EMULATION linker.  You can list the available
  315.      emulations with the `--verbose' option.  The default depends on
  316.      how your `ld' was configured.
  317.  
  318. `-N'
  319.      Set the text and data sections to be readable and writable.  Also,
  320.      do not page-align the data segment.  If the output format supports
  321.      Unix style magic numbers, mark the output as `OMAGIC'.
  322.  
  323. `-n'
  324.      Set the text segment to be read only, and mark the output as
  325.      `NMAGIC' if possible.
  326.  
  327. `-noinhibit-exec'
  328.      Retain the executable output file whenever it is still usable.
  329.      Normally, the linker will not produce an output file if it
  330.      encounters errors during the link process; it exits without
  331.      writing an output file when it issues any error whatsoever.
  332.  
  333. `-o OUTPUT'
  334.      Use OUTPUT as the name for the program produced by `ld'; if this
  335.      option is not specified, the name `a.out' is used by default.  The
  336.      script command `OUTPUT' can also specify the output file name.
  337.  
  338. `-oformat OUTPUT-FORMAT'
  339.      `ld' may be configured to support more than one kind of object
  340.      file.  If your `ld' is configured this way, you can use the
  341.      `-oformat' option to specify the binary format for the output
  342.      object file.  Even when `ld' is configured to support alternative
  343.      object formats, you don't usually need to specify this, as `ld'
  344.      should be configured to produce as a default output format the most
  345.      usual format on each machine.  OUTPUT-FORMAT is a text string, the
  346.      name of a particular format supported by the BFD libraries.  (You
  347.      can list the available binary formats with `objdump -i'.)  The
  348.      script command `OUTPUT_FORMAT' can also specify the output format,
  349.      but this option overrides it.  *Note BFD::.
  350.  
  351. `-R FILENAME'
  352.      Read symbol names and their addresses from FILENAME, but do not
  353.      relocate it or include it in the output.  This allows your output
  354.      file to refer symbolically to absolute locations of memory defined
  355.      in other programs.
  356.  
  357. `-relax'
  358.      An option with machine dependent effects.  Currently this option
  359.      is only supported on the H8/300 and the Intel 960.  *Note `ld' and
  360.      the H8/300: H8/300.  *Note `ld' and the Intel 960 family: i960.
  361.  
  362.      On some platforms, the `-relax' option performs global
  363.      optimizations that become possible when the linker resolves
  364.      addressing in the program, such as relaxing address modes and
  365.      synthesizing new instructions in the output object file.
  366.  
  367.      On platforms where this is not supported, `-relax' is accepted, but
  368.      ignored.
  369.  
  370. `-retain-symbols-file FILENAME'
  371.      Retain *only* the symbols listed in the file FILENAME, discarding
  372.      all others.  FILENAME is simply a flat file, with one symbol name
  373.      per line.  This option is especially useful in environments (such
  374.      as VxWorks) where a large global symbol table is accumulated
  375.      gradually, to conserve run-time memory.
  376.  
  377.      `-retain-symbols-file' does *not* discard undefined symbols, or
  378.      symbols needed for relocations.
  379.  
  380.      You may only specify `-retain-symbols-file' once in the command
  381.      line.  It overrides `-s' and `-S'.
  382.  
  383. `-rpath DIR'
  384.      Add a directory to the runtime library search path.  This is only
  385.      meaningful when linking an ELF executable with shared objects.  All
  386.      -rpath arguments are concatenated and passed to the runtime linker,
  387.      which uses them to locate shared objects at runtime.
  388.  
  389. `-r'
  390.      Generate relocatable output--i.e., generate an output file that
  391.      can in turn serve as input to `ld'.  This is often called "partial
  392.      linking".  As a side effect, in environments that support standard
  393.      Unix magic numbers, this option also sets the output file's magic
  394.      number to `OMAGIC'.  If this option is not specified, an absolute
  395.      file is produced.  When linking C++ programs, this option *will
  396.      not* resolve references to constructors; to do that, use `-Ur'.
  397.  
  398.      This option does the same thing as `-i'.
  399.  
  400. `-S'
  401.      Omit debugger symbol information (but not all symbols) from the
  402.      output file.
  403.  
  404. `-s'
  405.      Omit all symbol information from the output file.
  406.  
  407. `-soname NAME'
  408.      When creating an ELF shared object, set the internal DT_SONAME
  409.      field to the specified name.  When an executable is linked with a
  410.      shared object which has a DT_SONAME field, then when the
  411.      executable is run the dynamic linker will attempt to load the
  412.      shared object specified by the DT_SONAME field rather than the
  413.      using the file name given to the linker.
  414.  
  415. `-sort-common'
  416.      Normally, when `ld' places the global common symbols in the
  417.      appropriate output sections, it sorts them by size.  First come
  418.      all the one byte symbols, then all the two bytes, then all the
  419.      four bytes, and then everything else.  This is to prevent gaps
  420.      between symbols due to alignment constraints.  This option
  421.      disables that sorting.
  422.  
  423. `-stats'
  424.      Compute and display statistics about the operation of the linker,
  425.      such as execution time and memory usage.
  426.  
  427. `-Tbss ORG'
  428. `-Tdata ORG'
  429. `-Ttext ORG'
  430.      Use ORG as the starting address for--respectively--the `bss',
  431.      `data', or the `text' segment of the output file.  ORG must be a
  432.      single hexadecimal integer; for compatibility with other linkers,
  433.      you may omit the leading `0x' usually associated with hexadecimal
  434.      values.
  435.  
  436. `-T COMMANDFILE'
  437. `-TCOMMANDFILE'
  438.      Read link commands from the file COMMANDFILE.  These commands
  439.      replace `ld''s default link script (rather than adding to it), so
  440.      COMMANDFILE must specify everything necessary to describe the
  441.      target format.  *Note Commands::.  If COMMANDFILE does not exist,
  442.      `ld' looks for it in the directories specified by any preceding
  443.      `-L' options.  Multiple `-T' options accumulate.
  444.  
  445. `-t'
  446.      Print the names of the input files as `ld' processes them.
  447.  
  448. `-traditional-format'
  449.      For some targets, the output of `ld' is different in some ways from
  450.      the output of some existing linker.  This switch requests `ld' to
  451.      use the traditional format instead.
  452.  
  453.      For example, on SunOS, `ld' combines duplicate entries in the
  454.      symbol string table.  This can reduce the size of an output file
  455.      with full debugging information by over 30 percent.
  456.      Unfortunately, the SunOS `dbx' program can not read the resulting
  457.      program (`gdb' has no trouble).  The `-traditional-format' switch
  458.      tells `ld' to not combine duplicate entries.
  459.  
  460. `-u SYMBOL'
  461.      Force SYMBOL to be entered in the output file as an undefined
  462.      symbol.  Doing this may, for example, trigger linking of
  463.      additional modules from standard libraries.  `-u' may be repeated
  464.      with different option arguments to enter additional undefined
  465.      symbols.
  466.  
  467. `-Ur'
  468.      For anything other than C++ programs, this option is equivalent to
  469.      `-r': it generates relocatable output--i.e., an output file that
  470.      can in turn serve as input to `ld'.  When linking C++ programs,
  471.      `-Ur' *does* resolve references to constructors, unlike `-r'.  It
  472.      does not work to use `-Ur' on files that were themselves linked
  473.      with `-Ur'; once the constructor table has been built, it cannot
  474.      be added to.  Use `-Ur' only for the last partial link, and `-r'
  475.      for the others.
  476.  
  477. `--verbose'
  478.      Display the version number for `ld' and list the linker emulations
  479.      supported.  Display which input files can and cannot be opened.
  480.  
  481. `-v'
  482. `-V'
  483.      Display the version number for `ld'.
  484.  
  485. `-version'
  486.      Display the version number for `ld' and exit.
  487.  
  488. `-warn-common'
  489.      Warn when a common symbol is combined with another common symbol
  490.      or with a symbol definition.  Unix linkers allow this somewhat
  491.      sloppy practice, but linkers on some other operating systems do
  492.      not.  This option allows you to find potential problems from
  493.      combining global symbols.  Unfortunately, some C libraries use
  494.      this practice, so you may get some warnings about symbols in the
  495.      libraries as well as in your programs.
  496.  
  497.      There are three kinds of global symbols, illustrated here by C
  498.      examples:
  499.  
  500.     `int i = 1;'
  501.           A definition, which goes in the initialized data section of
  502.           the output file.
  503.  
  504.     `extern int i;'
  505.           An undefined reference, which does not allocate space.  There
  506.           must be either a definition or a common symbol for the
  507.           variable somewhere.
  508.  
  509.     `int i;'
  510.           A common symbol.  If there are only (one or more) common
  511.           symbols for a variable, it goes in the uninitialized data
  512.           area of the output file.  The linker merges multiple common
  513.           symbols for the same variable into a single symbol.  If they
  514.           are of different sizes, it picks the largest size.  The
  515.           linker turns a common symbol into a declaration, if there is
  516.           a definition of the same variable.
  517.  
  518.      The `-warn-common' option can produce five kinds of warnings.  Each
  519.      warning consists of a pair of lines: the first describes the
  520.      symbol just encountered, and the second describes the previous
  521.      symbol encountered with the same name.  One or both of the two
  522.      symbols will be a common symbol.
  523.  
  524.        1. Turning a common symbol into a reference, because there is
  525.           already a definition for the symbol.
  526.                FILE(SECTION): warning: common of `SYMBOL'
  527.                   overridden by definition
  528.                FILE(SECTION): warning: defined here
  529.  
  530.        2. Turning a common symbol into a reference, because a later
  531.           definition for the symbol is encountered.  This is the same
  532.           as the previous case, except that the symbols are encountered
  533.           in a different order.
  534.                FILE(SECTION): warning: definition of `SYMBOL'
  535.                   overriding common
  536.                FILE(SECTION): warning: common is here
  537.  
  538.        3. Merging a common symbol with a previous same-sized common
  539.           symbol.
  540.                FILE(SECTION): warning: multiple common
  541.                   of `SYMBOL'
  542.                FILE(SECTION): warning: previous common is here
  543.  
  544.        4. Merging a common symbol with a previous larger common symbol.
  545.                FILE(SECTION): warning: common of `SYMBOL'
  546.                   overridden by larger common
  547.                FILE(SECTION): warning: larger common is here
  548.  
  549.        5. Merging a common symbol with a previous smaller common
  550.           symbol.  This is the same as the previous case, except that
  551.           the symbols are encountered in a different order.
  552.                FILE(SECTION): warning: common of `SYMBOL'
  553.                   overriding smaller common
  554.                FILE(SECTION): warning: smaller common is here
  555.  
  556. `-warn-once'
  557.      Only warn once for each undefined symbol, rather than once per
  558.      module which refers to it.
  559.  
  560. `-X'
  561.      If `-s' or `-S' is also specified, delete only local symbols
  562.      beginning with `L'.
  563.  
  564. `-x'
  565.      If `-s' or `-S' is also specified, delete all local symbols, not
  566.      just those beginning with `L'.
  567.  
  568. `-y SYMBOL'
  569.      Print the name of each linked file in which SYMBOL appears.  This
  570.      option may be given any number of times.  On many systems it is
  571.      necessary to prepend an underscore.
  572.  
  573.      This option is useful when you have an undefined symbol in your
  574.      link but don't know where the reference is coming from.
  575.  
  576. `-( ARCHIVES -)'
  577. `--start-group ARCHIVES --end-group'
  578.      The ARCHIVES should be a list of archive files.  They may be
  579.      either explicit file names, or `-l' options.
  580.  
  581.      The specified archives are searched repeatedly until no new
  582.      undefined references are created.  Normally, an archive is
  583.      searched only once in the order that it is specified on the
  584.      command line.  If a symbol in that archive is needed to resolve an
  585.      undefined symbol referred to by an object in an archive that
  586.      appears later on the command line, the linker would not be able to
  587.      resolve that reference.  By grouping the archives, they all be
  588.      searched repeatedly until all possible references are resolved.
  589.  
  590.      Using this option has a significant performance cost.  It is best
  591.      to use it only when there are unavoidable circular references
  592.      between two or more archives.
  593.  
  594. 
  595. File: ld.info,  Node: Environment,  Prev: Options,  Up: Invocation
  596.  
  597. Environment Variables
  598. =====================
  599.  
  600.    You can change the behavior of `ld' with the environment variable
  601. `GNUTARGET'.
  602.  
  603.    `GNUTARGET' determines the input-file object format if you don't use
  604. `-b' (or its synonym `-format').  Its value should be one of the BFD
  605. names for an input format (*note BFD::.).  If there is no `GNUTARGET'
  606. in the environment, `ld' uses the natural format of the target. If
  607. `GNUTARGET' is set to `default' then BFD attempts to discover the input
  608. format by examining binary input files; this method often succeeds, but
  609. there are potential ambiguities, since there is no method of ensuring
  610. that the magic number used to specify object-file formats is unique.
  611. However, the configuration procedure for BFD on each system places the
  612. conventional format for that system first in the search-list, so
  613. ambiguities are resolved in favor of convention.
  614.  
  615. 
  616. File: ld.info,  Node: Commands,  Next: Machine Dependent,  Prev: Invocation,  Up: Top
  617.  
  618. Command Language
  619. ****************
  620.  
  621.    The command language provides explicit control over the link process,
  622. allowing complete specification of the mapping between the linker's
  623. input files and its output.  It controls:
  624.    * input files
  625.  
  626.    * file formats
  627.  
  628.    * output file layout
  629.  
  630.    * addresses of sections
  631.  
  632.    * placement of common blocks
  633.  
  634.    You may supply a command file (also known as a link script) to the
  635. linker either explicitly through the `-T' option, or implicitly as an
  636. ordinary file. If the linker opens a file which it cannot recognize as
  637. a supported object or archive format, it reports an error.
  638.  
  639. * Menu:
  640.  
  641. * Scripts::                     Linker Scripts
  642. * Expressions::                 Expressions
  643. * MEMORY::                      MEMORY Command
  644. * SECTIONS::                    SECTIONS Command
  645. * Entry Point::                 The Entry Point
  646. * Option Commands::             Option Commands
  647.  
  648. 
  649. File: ld.info,  Node: Scripts,  Next: Expressions,  Up: Commands
  650.  
  651. Linker Scripts
  652. ==============
  653.  
  654.    The `ld' command language is a collection of statements; some are
  655. simple keywords setting a particular option, some are used to select and
  656. group input files or name output files; and two statement types have a
  657. fundamental and pervasive impact on the linking process.
  658.  
  659.    The most fundamental command of the `ld' command language is the
  660. `SECTIONS' command (*note SECTIONS::.).  Every meaningful command
  661. script must have a `SECTIONS' command: it specifies a "picture" of the
  662. output file's layout, in varying degrees of detail.  No other command
  663. is required in all cases.
  664.  
  665.    The `MEMORY' command complements `SECTIONS' by describing the
  666. available memory in the target architecture.  This command is optional;
  667. if you don't use a `MEMORY' command, `ld' assumes sufficient memory is
  668. available in a contiguous block for all output.  *Note MEMORY::.
  669.  
  670.    You may include comments in linker scripts just as in C: delimited
  671. by `/*' and `*/'.  As in C, comments are syntactically equivalent to
  672. whitespace.
  673.  
  674. 
  675. File: ld.info,  Node: Expressions,  Next: MEMORY,  Prev: Scripts,  Up: Commands
  676.  
  677. Expressions
  678. ===========
  679.  
  680.    Many useful commands involve arithmetic expressions.  The syntax for
  681. expressions in the command language is identical to that of C
  682. expressions, with the following features:
  683.    * All expressions evaluated as integers and are of "long" or
  684.      "unsigned long" type.
  685.  
  686.    * All constants are integers.
  687.  
  688.    * All of the C arithmetic operators are provided.
  689.  
  690.    * You may reference, define, and create global variables.
  691.  
  692.    * You may call special purpose built-in functions.
  693.  
  694. * Menu:
  695.  
  696. * Integers::                    Integers
  697. * Symbols::                     Symbol Names
  698. * Location Counter::            The Location Counter
  699. * Operators::                   Operators
  700. * Evaluation::                  Evaluation
  701. * Assignment::                  Assignment: Defining Symbols
  702. * Arithmetic Functions::        Built-In Functions
  703.  
  704. 
  705. File: ld.info,  Node: Integers,  Next: Symbols,  Up: Expressions
  706.  
  707. Integers
  708. --------
  709.  
  710.    An octal integer is `0' followed by zero or more of the octal digits
  711. (`01234567').
  712.      _as_octal = 0157255;
  713.  
  714.    A decimal integer starts with a non-zero digit followed by zero or
  715. more digits (`0123456789').
  716.      _as_decimal = 57005;
  717.  
  718.    A hexadecimal integer is `0x' or `0X' followed by one or more
  719. hexadecimal digits chosen from `0123456789abcdefABCDEF'.
  720.      _as_hex = 0xdead;
  721.  
  722.    To write a negative integer, use the prefix operator `-'; *note
  723. Operators::..
  724.      _as_neg = -57005;
  725.  
  726.    Additionally the suffixes `K' and `M' may be used to scale a
  727. constant by `1024' or `1024*1024' respectively. For example, the
  728. following all refer to the same quantity:
  729.  
  730.              _fourk_1 = 4K;
  731.              _fourk_2 = 4096;
  732.              _fourk_3 = 0x1000;
  733.  
  734. 
  735. File: ld.info,  Node: Symbols,  Next: Location Counter,  Prev: Integers,  Up: Expressions
  736.  
  737. Symbol Names
  738. ------------
  739.  
  740.    Unless quoted, symbol names start with a letter, underscore, or point
  741. and may include any letters, underscores, digits, points, and hyphens.
  742. Unquoted symbol names must not conflict with any keywords.  You can
  743. specify a symbol which contains odd characters or has the same name as
  744. a keyword, by surrounding the symbol name in double quotes:
  745.              "SECTION" = 9;
  746.              "with a space" = "also with a space" + 10;
  747.  
  748.    Since symbols can contain many non-alphabetic characters, it is
  749. safest to delimit symbols with spaces.  For example, `A-B' is one
  750. symbol, whereas `A - B' is an expression involving subtraction.
  751.  
  752. 
  753. File: ld.info,  Node: Location Counter,  Next: Operators,  Prev: Symbols,  Up: Expressions
  754.  
  755. The Location Counter
  756. --------------------
  757.  
  758.    The special linker variable "dot" `.' always contains the current
  759. output location counter. Since the `.' always refers to a location in
  760. an output section, it must always appear in an expression within a
  761. `SECTIONS' command. The `.' symbol may appear anywhere that an ordinary
  762. symbol is allowed in an expression, but its assignments have a side
  763. effect. Assigning a value to the `.' symbol will cause the location
  764. counter to be moved.  This may be used to create holes in the output
  765. section.  The location counter may never be moved backwards.
  766.      SECTIONS
  767.      {
  768.        output :
  769.        {
  770.        file1(.text)
  771.        . = . + 1000;
  772.        file2(.text)
  773.        . += 1000;
  774.        file3(.text)
  775.        } = 0x1234;
  776.      }
  777.  
  778. In the previous example, `file1' is located at the beginning of the
  779. output section, then there is a 1000 byte gap.  Then `file2' appears,
  780. also with a 1000 byte gap following before `file3' is loaded.  The
  781. notation `= 0x1234' specifies what data to write in the gaps (*note
  782. Section Options::.).
  783.  
  784. 
  785. File: ld.info,  Node: Operators,  Next: Evaluation,  Prev: Location Counter,  Up: Expressions
  786.  
  787. Operators
  788. ---------
  789.  
  790.    The linker recognizes  the standard C set of arithmetic operators,
  791. with the standard bindings and precedence levels:
  792.      precedence      associativity   Operators                Notes
  793.      (highest)
  794.      1               left            !  -  ~                  (1)
  795.      2               left            *  /  %
  796.      3               left            +  -
  797.      4               left            >>  <<
  798.      5               left            ==  !=  >  <  <=  >=
  799.      6               left            &
  800.      7               left            |
  801.      8               left            &&
  802.      9               left            ||
  803.      10              right           ? :
  804.      11              right           &=  +=  -=  *=  /=       (2)
  805.      (lowest)
  806.    Notes: (1) Prefix operators (2) *Note Assignment::
  807.  
  808. 
  809. File: ld.info,  Node: Evaluation,  Next: Assignment,  Prev: Operators,  Up: Expressions
  810.  
  811. Evaluation
  812. ----------
  813.  
  814.    The linker uses "lazy evaluation" for expressions; it only calculates
  815. an expression when absolutely necessary.  The linker needs the value of
  816. the start address, and the lengths of memory regions, in order to do any
  817. linking at all; these values are computed as soon as possible when the
  818. linker reads in the command file.  However, other values (such as symbol
  819. values) are not known or needed until after storage allocation.  Such
  820. values are evaluated later, when other information (such as the sizes of
  821. output sections) is available for use in the symbol assignment
  822. expression.
  823.  
  824. 
  825. File: ld.info,  Node: Assignment,  Next: Arithmetic Functions,  Prev: Evaluation,  Up: Expressions
  826.  
  827. Assignment: Defining Symbols
  828. ----------------------------
  829.  
  830.    You may create global symbols, and assign values (addresses) to
  831. global symbols, using any of the C assignment operators:
  832.  
  833. `SYMBOL  = EXPRESSION ;'
  834. `SYMBOL &= EXPRESSION ;'
  835. `SYMBOL += EXPRESSION ;'
  836. `SYMBOL -= EXPRESSION ;'
  837. `SYMBOL *= EXPRESSION ;'
  838. `SYMBOL /= EXPRESSION ;'
  839.    Two things distinguish assignment from other operators in `ld'
  840. expressions.
  841.    * Assignment may only be used at the root of an expression; `a=b+3;'
  842.      is allowed, but `a+b=3;' is an error.
  843.  
  844.    * You must place a trailing semicolon (";") at the end of an
  845.      assignment statement.
  846.  
  847.    Assignment statements may appear:
  848.    * as commands in their own right in an `ld' script; or
  849.  
  850.    * as independent statements within a `SECTIONS' command; or
  851.  
  852.    * as part of the contents of a section definition in a `SECTIONS'
  853.      command.
  854.  
  855.    The first two cases are equivalent in effect--both define a symbol
  856. with an absolute address.  The last case defines a symbol whose address
  857. is relative to a particular section (*note SECTIONS::.).
  858.  
  859.    When a linker expression is evaluated and assigned to a variable, it
  860. is given either an absolute or a relocatable type. An absolute
  861. expression type is one in which the symbol contains the value that it
  862. will have in the output file; a relocatable expression type is one in
  863. which the value is expressed as a fixed offset from the base of a
  864. section.
  865.  
  866.    The type of the expression is controlled by its position in the
  867. script file.  A symbol assigned within a section definition is created
  868. relative to the base of the section; a symbol assigned in any other
  869. place is created as an absolute symbol. Since a symbol created within a
  870. section definition is relative to the base of the section, it will
  871. remain relocatable if relocatable output is requested.  A symbol may be
  872. created with an absolute value even when assigned to within a section
  873. definition by using the absolute assignment function `ABSOLUTE'.  For
  874. example, to create an absolute symbol whose address is the last byte of
  875. an output section named `.data':
  876.      SECTIONS{ ...
  877.        .data :
  878.          {
  879.            *(.data)
  880.            _edata = ABSOLUTE(.) ;
  881.          }
  882.      ... }
  883.  
  884.    The linker tries to put off the evaluation of an assignment until all
  885. the terms in the source expression are known (*note Evaluation::.).  For
  886. instance, the sizes of sections cannot be known until after allocation,
  887. so assignments dependent upon these are not performed until after
  888. allocation. Some expressions, such as those depending upon the location
  889. counter "dot", `.' must be evaluated during allocation. If the result
  890. of an expression is required, but the value is not available, then an
  891. error results.  For example, a script like the following
  892.      SECTIONS { ...
  893.        text 9+this_isnt_constant :
  894.          { ...
  895.          }
  896.      ... }
  897.  
  898. will cause the error message "`Non constant expression for initial
  899. address'".
  900.  
  901.    In some cases, it is desirable for a linker script to define a symbol
  902. only if it is referenced, and only if it is not defined by any object
  903. included in the link.  For example, traditional linkers defined the
  904. symbol `etext'.  However, ANSI C requires that the user be able to use
  905. `etext' as a function name without encountering an error.  The
  906. `PROVIDE' keyword may be used to define a symbol, such as `etext', only
  907. if it is referenced but not defined.  The syntax is `PROVIDE(SYMBOL =
  908. EXPRESSION)'.
  909.  
  910. 
  911. File: ld.info,  Node: Arithmetic Functions,  Prev: Assignment,  Up: Expressions
  912.  
  913. Arithmetic Functions
  914. --------------------
  915.  
  916.    The command language includes a number of built-in functions for use
  917. in link script expressions.
  918. `ABSOLUTE(EXP)'
  919.      Return the absolute (non-relocatable, as opposed to non-negative)
  920.      value of the expression EXP.  Primarily useful to assign an
  921.      absolute value to a symbol within a section definition, where
  922.      symbol values are normally section-relative.
  923.  
  924. `ADDR(SECTION)'
  925.      Return the absolute address of the named SECTION.  Your script must
  926.      previously have defined the location of that section. In the
  927.      following example, `symbol_1' and `symbol_2' are assigned identical
  928.      values:
  929.           SECTIONS{ ...
  930.             .output1 :
  931.               {
  932.               start_of_output_1 = ABSOLUTE(.);
  933.               ...
  934.               }
  935.             .output :
  936.               {
  937.               symbol_1 = ADDR(.output1);
  938.               symbol_2 = start_of_output_1;
  939.               }
  940.           ... }
  941.  
  942. `ALIGN(EXP)'
  943.      Return the result of the current location counter (`.') aligned to
  944.      the next EXP boundary.  EXP must be an expression whose value is a
  945.      power of two.  This is equivalent to
  946.           (. + EXP - 1) & ~(EXP - 1)
  947.  
  948.      `ALIGN' doesn't change the value of the location counter--it just
  949.      does arithmetic on it.  As an example, to align the output `.data'
  950.      section to the next `0x2000' byte boundary after the preceding
  951.      section and to set a variable within the section to the next
  952.      `0x8000' boundary after the input sections:
  953.           SECTIONS{ ...
  954.             .data ALIGN(0x2000): {
  955.               *(.data)
  956.               variable = ALIGN(0x8000);
  957.             }
  958.           ... }
  959.  
  960.      The first use of `ALIGN' in this example specifies the location of
  961.      a section because it is used as the optional START attribute of a
  962.      section definition (*note Section Options::.).  The second use
  963.      simply defines the value of a variable.
  964.  
  965.      The built-in `NEXT' is closely related to `ALIGN'.
  966.  
  967. `DEFINED(SYMBOL)'
  968.      Return 1 if SYMBOL is in the linker global symbol table and is
  969.      defined, otherwise return 0.  You can use this function to provide
  970.      default values for symbols.  For example, the following
  971.      command-file fragment shows how to set a global symbol `begin' to
  972.      the first location in the `.text' section--but if a symbol called
  973.      `begin' already existed, its value is preserved:
  974.  
  975.           SECTIONS{ ...
  976.             .text : {
  977.               begin = DEFINED(begin) ? begin : . ;
  978.               ...
  979.             }
  980.           ... }
  981.  
  982. `NEXT(EXP)'
  983.      Return the next unallocated address that is a multiple of EXP.
  984.      This function is closely related to `ALIGN(EXP)'; unless you use
  985.      the `MEMORY' command to define discontinuous memory for the output
  986.      file, the two functions are equivalent.
  987.  
  988. `SIZEOF(SECTION)'
  989.      Return the size in bytes of the named SECTION, if that section has
  990.      been allocated.  In the following example, `symbol_1' and
  991.      `symbol_2' are assigned identical values:
  992.           SECTIONS{ ...
  993.             .output {
  994.               .start = . ;
  995.               ...
  996.               .end = . ;
  997.               }
  998.             symbol_1 = .end - .start ;
  999.             symbol_2 = SIZEOF(.output);
  1000.           ... }
  1001.  
  1002. `SIZEOF_HEADERS'
  1003. `sizeof_headers'
  1004.      Return the size in bytes of the output file's headers.  You can
  1005.      use this number as the start address of the first section, if you
  1006.      choose, to facilitate paging.
  1007.  
  1008. 
  1009. File: ld.info,  Node: MEMORY,  Next: SECTIONS,  Prev: Expressions,  Up: Commands
  1010.  
  1011. Memory Layout
  1012. =============
  1013.  
  1014.    The linker's default configuration permits allocation of all
  1015. available memory.  You can override this configuration by using the
  1016. `MEMORY' command.  The `MEMORY' command describes the location and size
  1017. of blocks of memory in the target.  By using it carefully, you can
  1018. describe which memory regions may be used by the linker, and which
  1019. memory regions it must avoid.  The linker does not shuffle sections to
  1020. fit into the available regions, but does move the requested sections
  1021. into the correct regions and issue errors when the regions become too
  1022. full.
  1023.  
  1024.    A command file may contain at most one use of the `MEMORY' command;
  1025. however, you can define as many blocks of memory within it as you wish.
  1026. The syntax is:
  1027.  
  1028.      MEMORY
  1029.        {
  1030.          NAME (ATTR) : ORIGIN = ORIGIN, LENGTH = LEN
  1031.          ...
  1032.        }
  1033.  
  1034. `NAME'
  1035.      is a name used internally by the linker to refer to the region. Any
  1036.      symbol name may be used.  The region names are stored in a separate
  1037.      name space, and will not conflict with symbols, file names or
  1038.      section names.  Use distinct names to specify multiple regions.
  1039.  
  1040. `(ATTR)'
  1041.      is an optional list of attributes, permitted for compatibility
  1042.      with the AT&T linker but not used by `ld' beyond checking that the
  1043.      attribute list is valid.  Valid attribute lists must be made up of
  1044.      the characters "`LIRWX'".  If you omit the attribute list, you may
  1045.      omit the parentheses around it as well.
  1046.  
  1047. `ORIGIN'
  1048.      is the start address of the region in physical memory.  It is an
  1049.      expression that must evaluate to a constant before memory
  1050.      allocation is performed. The keyword `ORIGIN' may be abbreviated
  1051.      to `org' or `o' (but not, for example, `ORG').
  1052.  
  1053. `LEN'
  1054.      is the size in bytes of the region (an expression).  The keyword
  1055.      `LENGTH' may be abbreviated to `len' or `l'.
  1056.  
  1057.    For example, to specify that memory has two regions available for
  1058. allocation--one starting at 0 for 256 kilobytes, and the other starting
  1059. at `0x40000000' for four megabytes:
  1060.  
  1061.      MEMORY
  1062.        {
  1063.        rom : ORIGIN = 0, LENGTH = 256K
  1064.        ram : org = 0x40000000, l = 4M
  1065.        }
  1066.  
  1067.    Once you have defined a region of memory named MEM, you can direct
  1068. specific output sections there by using a command ending in `>MEM'
  1069. within the `SECTIONS' command (*note Section Options::.).  If the
  1070. combined output sections directed to a region are too big for the
  1071. region, the linker will issue an error message.
  1072.  
  1073. 
  1074. File: ld.info,  Node: SECTIONS,  Next: Entry Point,  Prev: MEMORY,  Up: Commands
  1075.  
  1076. Specifying Output Sections
  1077. ==========================
  1078.  
  1079.    The `SECTIONS' command controls exactly where input sections are
  1080. placed into output sections, their order in the output file, and to
  1081. which output sections they are allocated.
  1082.  
  1083.    You may use at most one `SECTIONS' command in a script file, but you
  1084. can have as many statements within it as you wish.  Statements within
  1085. the `SECTIONS' command can do one of three things:
  1086.  
  1087.    * define the entry point;
  1088.  
  1089.    * assign a value to a symbol;
  1090.  
  1091.    * describe the placement of a named output section, and which input
  1092.      sections go into it.
  1093.  
  1094.    You can also use the first two operations--defining the entry point
  1095. and defining symbols--outside the `SECTIONS' command: *note Entry
  1096. Point::., and *note Assignment::..  They are permitted here as well for
  1097. your convenience in reading the script, so that symbols and the entry
  1098. point can be defined at meaningful points in your output-file layout.
  1099.  
  1100.    If you do not use a `SECTIONS' command, the linker places each input
  1101. section into an identically named output section in the order that the
  1102. sections are first encountered in the input files.  If all input
  1103. sections are present in the first file, for example, the order of
  1104. sections in the output file will match the order in the first input
  1105. file.
  1106.  
  1107. * Menu:
  1108.  
  1109. * Section Definition::          Section Definitions
  1110. * Section Placement::           Section Placement
  1111. * Section Data Expressions::    Section Data Expressions
  1112. * Section Options::             Optional Section Attributes
  1113.  
  1114. 
  1115. File: ld.info,  Node: Section Definition,  Next: Section Placement,  Up: SECTIONS
  1116.  
  1117. Section Definitions
  1118. -------------------
  1119.  
  1120.    The most frequently used statement in the `SECTIONS' command is the
  1121. "section definition", which specifies the properties of an output
  1122. section: its location, alignment, contents, fill pattern, and target
  1123. memory region.  Most of these specifications are optional; the simplest
  1124. form of a section definition is
  1125.      SECTIONS { ...
  1126.        SECNAME : {
  1127.          CONTENTS
  1128.        }
  1129.      ... }
  1130.  
  1131. SECNAME is the name of the output section, and CONTENTS a specification
  1132. of what goes there--for example, a list of input files or sections of
  1133. input files (*note Section Placement::.).  As you might assume, the
  1134. whitespace shown is optional.  You do need the colon `:' and the braces
  1135. `{}', however.
  1136.  
  1137.    SECNAME must meet the constraints of your output format.  In formats
  1138. which only support a limited number of sections, such as `a.out', the
  1139. name must be one of the names supported by the format (`a.out', for
  1140. example, allows only `.text', `.data' or `.bss'). If the output format
  1141. supports any number of sections, but with numbers and not names (as is
  1142. the case for Oasys), the name should be supplied as a quoted numeric
  1143. string.  A section name may consist of any sequence of characters, but
  1144. any name which does not conform to the standard `ld' symbol name syntax
  1145. must be quoted.  *Note Symbol Names: Symbols.
  1146.  
  1147.    The linker will not create output sections which do not have any
  1148. contents.  This is for convenience when referring to input sections that
  1149. may or may not exist.  For example,
  1150.      .foo { *(.foo }
  1151.    will only create a `.foo' section in the output file if there is a
  1152. `.foo' section in at least one input file.
  1153.  
  1154. 
  1155. File: ld.info,  Node: Section Placement,  Next: Section Data Expressions,  Prev: Section Definition,  Up: SECTIONS
  1156.  
  1157. Section Placement
  1158. -----------------
  1159.  
  1160.    In a section definition, you can specify the contents of an output
  1161. section by listing particular input files, by listing particular
  1162. input-file sections, or by a combination of the two.  You can also place
  1163. arbitrary data in the section, and define symbols relative to the
  1164. beginning of the section.
  1165.  
  1166.    The CONTENTS of a section definition may include any of the
  1167. following kinds of statement.  You can include as many of these as you
  1168. like in a single section definition, separated from one another by
  1169. whitespace.
  1170.  
  1171. `FILENAME'
  1172.      You may simply name a particular input file to be placed in the
  1173.      current output section; *all* sections from that file are placed
  1174.      in the current section definition.  If the file name has already
  1175.      been mentioned in another section definition, with an explicit
  1176.      section name list, then only those sections which have not yet
  1177.      been allocated are used.
  1178.  
  1179.      To specify a list of particular files by name:
  1180.           .data : { afile.o bfile.o cfile.o }
  1181.  
  1182.      The example also illustrates that multiple statements can be
  1183.      included in the contents of a section definition, since each file
  1184.      name is a separate statement.
  1185.  
  1186. `FILENAME( SECTION )'
  1187. `FILENAME( SECTION, SECTION, ... )'
  1188. `FILENAME( SECTION SECTION ... )'
  1189.      You can name one or more sections from your input files, for
  1190.      insertion in the current output section.  If you wish to specify a
  1191.      list of input-file sections inside the parentheses, you may
  1192.      separate the section names by either commas or whitespace.
  1193.  
  1194. `* (SECTION)'
  1195. `* (SECTION, SECTION, ...)'
  1196. `* (SECTION SECTION ...)'
  1197.      Instead of explicitly naming particular input files in a link
  1198.      control script, you can refer to *all* files from the `ld' command
  1199.      line: use `*' instead of a particular file name before the
  1200.      parenthesized input-file section list.
  1201.  
  1202.      If you have already explicitly included some files by name, `*'
  1203.      refers to all *remaining* files--those whose places in the output
  1204.      file have not yet been defined.
  1205.  
  1206.      For example, to copy sections `1' through `4' from an Oasys file
  1207.      into the `.text' section of an `a.out' file, and sections `13' and
  1208.      `14' into the `.data' section:
  1209.           SECTIONS {
  1210.             .text :{
  1211.               *("1" "2" "3" "4")
  1212.             }
  1213.           
  1214.             .data :{
  1215.               *("13" "14")
  1216.             }
  1217.           }
  1218.  
  1219.      `[ SECTION ... ]' used to be accepted as an alternate way to
  1220.      specify named sections from all unallocated input files.  Because
  1221.      some operating systems (VMS) allow brackets in file names, that
  1222.      notation is no longer supported.
  1223.  
  1224. `FILENAME`( COMMON )''
  1225. `*( COMMON )'
  1226.      Specify where in your output file to place uninitialized data with
  1227.      this notation.  `*(COMMON)' by itself refers to all uninitialized
  1228.      data from all input files (so far as it is not yet allocated);
  1229.      FILENAME`(COMMON)' refers to uninitialized data from a particular
  1230.      file.  Both are special cases of the general mechanisms for
  1231.      specifying where to place input-file sections: `ld' permits you to
  1232.      refer to uninitialized data as if it were in an input-file section
  1233.      named `COMMON', regardless of the input file's format.
  1234.  
  1235.    For example, the following command script arranges the output file
  1236. into three consecutive sections, named `.text', `.data', and `.bss',
  1237. taking the input for each from the correspondingly named sections of
  1238. all the input files:
  1239.  
  1240.      SECTIONS {
  1241.        .text : { *(.text) }
  1242.        .data : { *(.data) }
  1243.        .bss :  { *(.bss)  *(COMMON) }
  1244.      }
  1245.  
  1246.    The following example reads all of the sections from file `all.o'
  1247. and places them at the start of output section `outputa' which starts
  1248. at location `0x10000'. All of section `.input1' from file `foo.o'
  1249. follows immediately, in the same output section.  All of section
  1250. `.input2' from `foo.o' goes into output section `outputb', followed by
  1251. section `.input1' from `foo1.o'.  All of the remaining `.input1' and
  1252. `.input2' sections from any files are written to output section
  1253. `outputc'.
  1254.  
  1255.      SECTIONS {
  1256.        outputa 0x10000 :
  1257.          {
  1258.          all.o
  1259.          foo.o (.input1)
  1260.          }
  1261.        outputb :
  1262.          {
  1263.          foo.o (.input2)
  1264.          foo1.o (.input1)
  1265.          }
  1266.        outputc :
  1267.          {
  1268.          *(.input1)
  1269.          *(.input2)
  1270.          }
  1271.      }
  1272.  
  1273.